package com.xueyi.system.wlw.controller;

import com.xueyi.system.wlw.domain.query.BaseWlwQuery;
import com.xueyi.system.wlw.domain.dto.BaseWlwDto;
import com.xueyi.system.wlw.service.IBaseWlwService;
import com.xueyi.common.web.entity.controller.BaseController;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xueyi.common.security.annotation.Logical;
import com.xueyi.common.security.annotation.RequiresPermissions;
import com.xueyi.common.core.web.validate.V_A;
import com.xueyi.common.core.web.validate.V_E;
import com.xueyi.common.core.web.result.AjaxResult;
import com.xueyi.common.log.annotation.Log;
import com.xueyi.common.log.enums.BusinessType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.List;

/**
 * 物联网管理 业务处理
 *
 * @author yanhe
 */
@RestController
@RequestMapping("/wlw")
public class BaseWlwController extends BaseController<BaseWlwQuery, BaseWlwDto, IBaseWlwService> {

    /** 定义节点名称 */
    @Override
    protected String getNodeName() {
        return "物联网" ;
    }

    /**
     * 查询物联网列表
     */
    @Override
    @GetMapping("/list")
    @RequiresPermissions(Auth.BASE_WLW_LIST)
    public AjaxResult list(BaseWlwQuery wlw) {
        return super.list(wlw);
    }

    /**
     * 查询物联网详细
     */
    @Override
    @GetMapping(value = "/{id}")
    @RequiresPermissions(Auth.BASE_WLW_SINGLE)
    public AjaxResult getInfoExtra(@PathVariable Serializable id) {
        return super.getInfoExtra(id);
    }

    /**
     * 物联网导出
     */
    @Override
    @PostMapping("/export")
    @RequiresPermissions(Auth.BASE_WLW_EXPORT)
    @Log(title = "物联网管理", businessType = BusinessType.EXPORT)
    public void export(HttpServletResponse response, BaseWlwQuery wlw) {
        super.export(response, wlw);
    }

    /**
     * 物联网新增
     */
    @Override
    @PostMapping
    @RequiresPermissions(Auth.BASE_WLW_ADD)
    @Log(title = "物联网管理", businessType = BusinessType.INSERT)
    public AjaxResult add(@Validated({V_A.class}) @RequestBody BaseWlwDto wlw) {
        return super.add(wlw);
    }

    /**
     * 物联网修改
     */
    @Override
    @PutMapping
    @RequiresPermissions(Auth.BASE_WLW_EDIT)
    @Log(title = "物联网管理", businessType = BusinessType.UPDATE)
    public AjaxResult edit(@Validated({V_E.class}) @RequestBody BaseWlwDto wlw) {
        return super.edit(wlw);
    }

    /**
     * 物联网修改状态
     */
    @Override
    @PutMapping("/status")
    @RequiresPermissions(value = {Auth.BASE_WLW_EDIT, Auth.BASE_WLW_ES}, logical = Logical.OR)
    @Log(title = "物联网管理", businessType = BusinessType.UPDATE_STATUS)
    public AjaxResult editStatus(@RequestBody BaseWlwDto wlw) {
        return super.editStatus(wlw);
    }

    /**
     * 物联网批量删除
     */
    @Override
    @DeleteMapping("/batch/{idList}")
    @RequiresPermissions(Auth.BASE_WLW_DEL)
    @Log(title = "物联网管理", businessType = BusinessType.DELETE)
    public AjaxResult batchRemove(@PathVariable List<Long> idList) {
        return super.batchRemove(idList);
    }

    /**
     * 获取物联网选择框列表
     */
    @Override
    @GetMapping("/option")
    public AjaxResult option() {
        return super.option();
    }

    interface Auth {
        /** 系统 - 物联网管理 - 列表 */
        String BASE_WLW_LIST = "system:wlw:list" ;
        /** 系统 - 物联网管理 - 详情 */
        String BASE_WLW_SINGLE = "system:wlw:single" ;
        /** 系统 - 物联网管理 - 新增 */
        String BASE_WLW_ADD = "system:wlw:add" ;
        /** 系统 - 物联网管理 - 修改 */
        String BASE_WLW_EDIT = "system:wlw:edit" ;
        /** 系统 - 物联网管理 - 修改状态 */
        String BASE_WLW_ES = "system:wlw:es" ;
        /** 系统 - 物联网管理 - 删除 */
        String BASE_WLW_DEL = "system:wlw:delete" ;
        /** 系统 - 物联网管理 - 导出 */
        String BASE_WLW_EXPORT = "system:wlw:export" ;
    }
}
